<?php
namespace app\api\controller;
/**
 * Created by PhpStorm.
 * User: zhou
 * Date: 2018/3/15
 * Time: 11:09
 */

use think\Controller;
use think\Request;
use think\Db;

class Base extends Controller {
    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $post = request()->post();
        if(isset($post['sign'])){
            $sign  = json_decode($post['sign'],true);
            if($sign['type'] == 'app'){
                if($sign['user_id'] != 0){
                    $user = Db::name('user')->where('id',$sign['user_id'])->find();
                    if($user['app_token'] != $sign['token']){
                        $msg['status'] = 220;
                        $msg['msg']    = '登录失效';
                        $msg['token'] = $user['app_token'];
                        echo json_encode($msg);exit;
                    }
                }
            }
        }
    }
}